#!/usr/bin/env bash
function is_installed() {
if (puppet module list | grep $1) ; then
    return 1; #false 
else
    return 0; #true 
fi
}

function install_module() {
if is_installed $1 ; then
    puppet module install $1 --modulepath $MODULE_DIR --force 
else
    echo $1 already installed
fi
}

MODULE_DIR=/etc/puppet/modules
mkdir -p $MODULE_DIR
cd $MODULE_DIR
MODULE=puppet-module
if (gem list --local | grep $MODULE) ; then
	echo installing $MODULE
    gem install $MODULE
else
	echo $MODULE already installed
fi
#install_module example42-yum
#install_module example42-puppi
#install_module example42-tomcat
install_module arnoudj-sudo

#git clone git://github.com/example42/puppet-tomcat.git $MODULE_DIR/puppet-tomcat  
